package com.toptech.downloadmanager;

import android.os.Parcel;
import android.os.Parcelable;

import java.io.File;

/**
 * @author zhengshaorui
 *
 */
public class FileInfo implements Parcelable{

	private long id;  //每一个info信息的id；对应 Taskinfo的id；
	private String apkurl;  //文件url
	private String fileName; //文件名
	private String fileDir;  //文件存储地址
	private File Dir;      //文件存储file数据
	private long length;   // 文件长度
	private int threadCount;  //文件线程个数
	private int progress;   //文件进度
	private String filedownsize; //文件下载的大小，需要转换，这里用float
	private String filesize; //文件下载的总大小，需要转换，这里用float
	private int filestatus;  //文件的下载状态
	private int btnstatus;  //文件 btn的状态
	private float speed;   //文件下载进度
	private String errorMsg;  //错误信息
	private int priority; //文件优先级


	protected FileInfo(Parcel in) {
		id = in.readLong();
		apkurl = in.readString();
		fileName = in.readString();
		fileDir = in.readString();
		length = in.readLong();
		threadCount = in.readInt();
		progress = in.readInt();
		filedownsize = in.readString();
		filesize = in.readString();
		filestatus = in.readInt();
		btnstatus = in.readInt();
		speed = in.readFloat();
		errorMsg = in.readString();
		priority = in.readInt();
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeLong(id);
		dest.writeString(apkurl);
		dest.writeString(fileName);
		dest.writeString(fileDir);
		dest.writeLong(length);
		dest.writeInt(threadCount);
		dest.writeInt(progress);
		dest.writeString(filedownsize);
		dest.writeString(filesize);
		dest.writeInt(filestatus);
		dest.writeInt(btnstatus);
		dest.writeFloat(speed);
		dest.writeString(errorMsg);
		dest.writeInt(priority);
	}

	@Override
	public int describeContents() {
		return 0;
	}

	public static final Creator<FileInfo> CREATOR = new Creator<FileInfo>() {
		@Override
		public FileInfo createFromParcel(Parcel in) {
			return new FileInfo(in);
		}

		@Override
		public FileInfo[] newArray(int size) {
			return new FileInfo[size];
		}
	};

	public FileInfo() {
	}

	public FileInfo(long id, String apkurl, String fileName, String fileDir, File dir, long length,
					int threadCount, int progress, String filedownsize, String filesize,
					int filestatus, int btnstatus, float speed, String errorMsg, int priority) {
		this.id = id;
		this.apkurl = apkurl;
		this.fileName = fileName;
		this.fileDir = fileDir;
		Dir = dir;
		this.length = length;
		this.threadCount = threadCount;
		this.progress = progress;
		this.filedownsize = filedownsize;
		this.filesize = filesize;
		this.filestatus = filestatus;
		this.btnstatus = btnstatus;
		this.speed = speed;
		this.errorMsg = errorMsg;
		this.priority = priority;
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getApkurl() {
		return apkurl;
	}

	public void setApkurl(String apkurl) {
		this.apkurl = apkurl;
	}

	public String getFileName() {
		return fileName;
	}

	public void setFileName(String fileName) {
		this.fileName = fileName;
	}

	public String getFileDir() {
		return fileDir;
	}

	public void setFileDir(String fileDir) {
		this.fileDir = fileDir;
	}

	public File getDir() {
		return Dir;
	}

	public void setDir(File dir) {
		Dir = dir;
	}

	public long getLength() {
		return length;
	}

	public void setLength(long length) {
		this.length = length;
	}

	public int getThreadCount() {
		return threadCount;
	}

	public void setThreadCount(int threadCount) {
		this.threadCount = threadCount;
	}

	public int getProgress() {
		return progress;
	}

	public void setProgress(int progress) {
		this.progress = progress;
	}

	public String getFiledownsize() {
		return filedownsize;
	}

	public void setFiledownsize(String filedownsize) {
		this.filedownsize = filedownsize;
	}

	public String getFilesize() {
		return filesize;
	}

	public void setFilesize(String filesize) {
		this.filesize = filesize;
	}

	public int getFilestatus() {
		return filestatus;
	}

	public void setFilestatus(int filestatus) {
		this.filestatus = filestatus;
	}

	public int getBtnstatus() {
		return btnstatus;
	}

	public void setBtnstatus(int btnstatus) {
		this.btnstatus = btnstatus;
	}

	public float getSpeed() {
		return speed;
	}

	public void setSpeed(float speed) {
		this.speed = speed;
	}

	public String getErrorMsg() {
		return errorMsg;
	}

	public void setErrorMsg(String errorMsg) {
		this.errorMsg = errorMsg;
	}

	public int getPriority() {
		return priority;
	}

	public void setPriority(int priority) {
		this.priority = priority;
	}


	@Override
	public String toString() {
		return "FileInfo{" +
				"id=" + id +
				", apkurl='" + apkurl + '\'' +
				", fileName='" + fileName + '\'' +
				", fileDir='" + fileDir + '\'' +
				", Dir=" + Dir +
				", length=" + length +
				", threadCount=" + threadCount +
				", progress=" + progress +
				", filedownsize='" + filedownsize + '\'' +
				", filesize='" + filesize + '\'' +
				", filestatus=" + filestatus +
				", btnstatus=" + btnstatus +
				", speed=" + speed +
				", errorMsg='" + errorMsg + '\'' +
				", priority=" + priority +
				'}';
	}
}
